<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Allusers_model extends CI_Model
{
	
	public function __construct()
	{
		parent::__construct();

	}
	function users_getall()
	{
		$users = $this->db->get('users');
	    return $users->result();
	}
	public function usertype_getall()
	{
		$this->db->select('user_type.*,users_groups.*');
		$this->db->from('user_type');
		$this->db->join('users_groups', 'user_type_id = user_type.id');
	 	return $this->db->get()->result();
	}
	
	
	public function get_employees()
	{
		$this->db->select ('users.*');
		//$this->db->distinct('user_type.name');
		$this->db->from('users_groups');
		$this->db->join('users','users_groups.user_id = users.id');
		$this->db->where('users_groups.group_id !=',1);
		$this->db->where('users_groups.group_id !=',7);
		$this->db->where('users.active !=',0);
		return $this->db->get()->result();
	}

		public function count_developers()
	{
		$this->db->select ('users.*','user_type_id.*','users_groups.*');
		$this->db->where('user_type_id',2);
		$this->db->from('users_groups'); 
		$this->db->join('users','users_groups.user_id = users.id');
		$this->db->where('users.active !=',0);
		return $this->db->count_all_results();
	}
	
	public function count_designers()
	{
		$this->db->select ('users.*','user_type_id.*','users_groups.*');
		$this->db->where('user_type_id',3);
		$this->db->from('users_groups');
		$this->db->join('users','users_groups.user_id = users.id');
		$this->db->where('users.active !=',0);
		return $this->db->count_all_results();
	}

	public function count_content_writers()
	{
		$this->db->select ('users.*','user_type_id.*','users_groups.*');
		$this->db->where('user_type_id',4);
		$this->db->from('users_groups');
		$this->db->join('users','users_groups.user_id = users.id');
		$this->db->where('users.active !=',0);
		return $this->db->count_all_results();
	}
	
	

}